package api

import (
	"client/global"
	"context"
	"github.com/gin-gonic/gin"
	"log"
	"server/proto"
)

func UserLogin(c *gin.Context) {
	username := c.PostForm("username")
	password := c.PostForm("password")
	res, err := global.RpcClient.UserLogin(context.Background(), &proto.UserLoginReq{
		Username: username,
		Password: password,
	})
	log.Println(err, "99999")
	if err != nil {
		c.JSON(200, gin.H{
			"code": -1,
			"msg":  err.Error(),
		})
		return
	}
	c.JSON(200, gin.H{
		"code":   200,
		"msg":    "登录成功",
		"userid": res.Userid,
	})
	log.Println("1`234333")
	return
}
